import { OperationConfigType } from '@/components/TableList'

const setOperationData = function (
  configData: OperationConfigType[],
  relateFn: any
): OperationConfigType[] {
  return configData.map((item: any) => ({
    ...item,
    onClick: relateFn[item.type]
  }))
}

export function useOperationConfig(
  configData: OperationConfigType[],
  relateFn: any
) {
  const operationConfig: OperationConfigType[] = setOperationData(
    configData,
    relateFn
  )
  return { operationConfig }
}

export default useOperationConfig